﻿using System.Windows.Navigation;
using SC2TV.ViewModel;

namespace SC2TV
{
    public partial class PrivateMessageWriterPage
    {
        public PrivateMessageWriterPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string requestUrl;
            string userName;
            string formID;
            string token;
            if (NavigationContext.QueryString.TryGetValue("requestUrl", out requestUrl))
            {
                NavigationContext.QueryString.TryGetValue("userName", out userName);
                NavigationContext.QueryString.TryGetValue("formID", out formID);
                NavigationContext.QueryString.TryGetValue("token", out token);
                var vm = DataContext as PrivateMessageWriterViewModel;
                vm.Load(requestUrl, userName, token, formID);
            }
            else
            {
                NavigationService.GoBack();
            }
        }
    }
}